#!/bin/bash
echo "启动系统，请输入以下程序端口"
echo "dh-web:9080 dh-app:9081"
ARR=(9080 9081)
echo "请输入要重启的程序端口号:"
read   print &&
echo "将要重启端口号："$print
if [[ "${ARR[*]}" =~ $print ]];then
echo "端口输入正确.."
else
echo "未知端口"
exit 1
fi
sudo lsof -i:$print
pid=$(ps -ef | sudo lsof -i:$print | sed -n "2, 1p" | awk '{print $2}')
echo  "正在kill  pid:"$pid"  端口为:"$print
sudo kill -9 $pid
if [ $print == "9080" ] ; then
echo "正在启动dh-web大华系统管理后台....."
cd /home/alert/project/server/
sudo nohup /home/alert/jdk/jdk21.0.4/bin/java -Dspring.profiles.active=test -jar /home/alert/project/server/iot-dh-web-0.0.1-SNAPSHOT.jar > /home/alert/project/server/web.log 2>&1 &
sleep 5
tail -fn 2000 /home/alert/project/server/web.log
elif [ $print == "9081" ] ; then
echo "正在启动dh-app大华系统移动端API....."
cd /home/alert/project/server/
sudo nohup /home/alert/jdk/jdk21.0.4/bin/java -Dspring.profiles.active=test -jar /home/alert/project/server/iot-dh-applet-0.0.1-SNAPSHOT.jar > /home/alert/project/server/app.log 2>&1 &
sleep 5
tail -fn 2000 /home/alert/project/server/app.log
else
echo "未知端口"
exit 1
fi